#coding=utf-8
import mysql_connect
# 进行数据库查询购买申请后的id和code
def id(mobile):
    connect = mysql_connect.mysql_connect()[0]  # connect是由connect_mysql函数返回的第一个值
    cursor = connect.cursor()
    # SQL 查询语句
    sql = "SELECT id from gdgyun_community.community_purchase_apply WHERE purchaser_mobile ="+mobile
    # 执行sql语句
    cursor.execute(sql)
    result = cursor.fetchall()
    connect.commit()  # 实例提交命令
    id = str(result[0][0])
    return id   #返回购买申请后的id
def code(mobile):
    connect = mysql_connect.mysql_connect()[0]  # connect是由connect_mysql函数返回的第一个值
    cursor = connect.cursor()
    # SQL 查询语句
    # SQL 查询语句
    sql = "SELECT id from gdgyun_community.community_purchase_apply WHERE purchaser_mobile =" + mobile
    # 执行sql语句
    cursor.execute(sql)
    result = cursor.fetchall()
    connect.commit()  # 实例提交命令
    id = str(result[0][0])
    sql_payment_code = "SELECT payment_code from gdgyun_community.community_payment_order WHERE community_purchase_apply_id =" + id
    cursor.execute(sql_payment_code)
    code = cursor.fetchall()
    connect.commit()  # 实例提交命令
    code = str(code[0][0])
    return code  # 返回购买申请后的code
if __name__ == '__main__':
    id('17781108472')
    code('17781108472')